import time
from ding_api import upload_attendance_record, get_access_token


def time_to_int(date_time):
    return int(time.mktime(time.strptime(date_time, "%Y-%m-%d %H:%M:%S"))) * 1000

access_token = get_access_token().get('access_token') or None

buka_list = [
    {"user_id": "xxxxxxxxxxxxxxxx", "date_time": time_to_int("2022-08-30 08:25:36"), "device_name": "厂房南门考勤机", "device_id": 251},
    # {"user_id": "xxxxxxxxxxxxxxxx", "date_time": time_to_int("2022-08-25 08:11:48"), "device_name": "厂房南门考勤机", "device_id": 251},
    # {"user_id": "xxxxxxxxxxxxxxxx", "date_time": time_to_int("2022-08-16 08:28:37"), "device_name": "厂房南门考勤机", "device_id": 251},
    # {"user_id": "xxxxxxxxxxxxxxxx", "date_time": time_to_int("2022-08-16 19:07:56"), "device_name": "厂房南门考勤机", "device_id": 251},
    ]

for item in buka_list:
    rel = upload_attendance_record(access_token, item.get('user_id'), item.get('device_name'), item.get('device_id'), item.get('date_time'))
    print(rel) # 根据返回结果，自己判断是否执行成功！